package jd;

import java.util.*;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2024/11/9-上午11:21
 * Since  :   1.0
 * Version:   1.0
 */
public class dikxiao {

    public static void main(String[] args) {
//        int nums[]={5,4,3,2,1};
//        int k=2;
//        ArrayList<Integer> result = findResult(nums, k);
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = scanner.nextInt();
        }
        ArrayList<Integer> result = findResult(nums, k);
        for (int i : result) {
            System.out.print(i);
        }


    }


    // 0 0 0 0 0
    // 4 5 0 0 0
    public static ArrayList<Integer> findResult(int nums[], int k) {
        ArrayList<Integer> result = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            ArrayList<Integer> integers = new ArrayList<>();
            for (int j = 0; j <= i; j++) {
                integers.add(nums[j]);
            }
            int min = findMin(k, integers);
            result.add(min);


        }
        return result;


    }

    //2 3 4 5
   // 3
    public static int findMin(int k, ArrayList<Integer> nums) {
        if (nums.size() < k) {
            return -1;
        }
        Collections.sort(nums);
        return nums.get(k - 1);

    }
}
